package com.haiyou.dc.thread;

public class TestJoin {

    public static void main(String[] args) throws InterruptedException {
        Thread thread = new Thread(() -> {
            for (int i = 0; i < 100; i++) {
                System.out.println("Thread------->" + i);
            }
        });

        thread.start();

        for (int i = 0; i < 30; i++) {
            //当=20时候，必须等线程执行完毕，再执行main线程
            if (i == 20) {
                thread.join();
            }
            System.out.println("main------->" + i);
        }
    }
}
